package com.yhm.action;

import java.io.UnsupportedEncodingException;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;
import com.yhm.service.RedoManager;
import com.yhm.util.page.RedoPage;

@SuppressWarnings("serial")
@Component("redo")
@Scope("prototype")
public class RedoAction extends ActionSupport {
	
	private String json;
	private RedoManager redoManager;
	private RedoPage page;
	private String companyNum;
	private String department;
	private String begin_time;
	private String end_time;
	
	public String manager(){
		return SUCCESS;
	}
	
	public String stat(){
		return SUCCESS;
	}
	
	//重做列表
	public String redo_list(){
		if(page == null)
			page = new RedoPage();
		json = redoManager.get_redo_list(page);
		return "json";
	}

	//重做过程
	public String redo_see(){
		try {
			department = new String(department.getBytes("ISO-8859-1"), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		json = redoManager.get_redo_see(companyNum, department);
		return "json";
	}
	
	//重做统计
	public String redo_stat(){
		if(department.equals("0")){
			json = redoManager.get_redo_stat(begin_time, end_time);
		}else{
			json = redoManager.get_redo_stat(department, begin_time, end_time);
		}
		//System.out.println(json);
		return "json";
	}
	
	
	public RedoManager getRedoManager() {
		return redoManager;
	}

	@Resource(name = "redoManager")
	public void setRedoManager(RedoManager redoManager) {
		this.redoManager = redoManager;
	}

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public RedoPage getPage() {
		return page;
	}

	public void setPage(RedoPage page) {
		this.page = page;
	}

	public String getCompanyNum() {
		return companyNum;
	}

	public void setCompanyNum(String companyNum) {
		this.companyNum = companyNum;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getBegin_time() {
		return begin_time;
	}

	public void setBegin_time(String begin_time) {
		this.begin_time = begin_time;
	}

	public String getEnd_time() {
		return end_time;
	}

	public void setEnd_time(String end_time) {
		this.end_time = end_time;
	}
	
}
